package com.smt.ejb3.tutoria.entitybean.many2many;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

@Entity
public class Role implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private int id;
	private String name;
	private Set<Staff> staffs;
	
	@Id
	@Column(name="ROLE_ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name="ROLE_STAFF", 
		joinColumns=
			@JoinColumn(name="CI_ROLE_ID",
						referencedColumnName="ROLE_ID"),
		inverseJoinColumns=
			@JoinColumn(name="CI_STAFF_ID",
						referencedColumnName="STAFF_ID"))
	public Set<Staff> getStaffs() {
		return staffs;
	}
	public void setStaffs(Set<Staff> staffs) {
		this.staffs = staffs;
	}
}
